
/** 使单例化 */
export function singleton(constructor: Function) {
    Object.defineProperty(constructor, 'instance', {
        configurable: true,
        get: function () {
            if (!this._instance || !(this._instance instanceof this))
                this._instance = new this();
            return this._instance;
        }
    })
}